package com.yanqu.road.server.logic.season.washe;

import com.yanqu.road.entity.activity.washe.config.WasheConfig;
import com.yanqu.road.entity.activity.washe.data.WasheUserData;
import com.yanqu.road.entity.enums.eSeasonRewardType;
import com.yanqu.road.entity.log.LogWasheSeasonReward;
import com.yanqu.road.entity.season.SeasonRewardConfig;
import com.yanqu.road.entity.season.SeasonRewardData;
import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.washe.WasheModule;
import com.yanqu.road.server.logic.season.BaseSeasonReward;
import com.yanqu.road.server.manger.log.AutoLogMgr;

public class WasheNewHandScoreArchCondition extends BaseSeasonReward {

    public WasheNewHandScoreArchCondition(eSeasonRewardType type, GamePlayer player) {
        super(type, player);
    }

    @Override
    protected int initSeasonId() {
        return WasheConfig.SEASON_ID_NULL;
    }

    @Override
    protected int initSystemId() {
        return eSystemId.WasheActivity.getValue();
    }

    @Override
    protected boolean canChange(SeasonRewardConfig config, SeasonRewardData data, Object param) {
        return true;
    }

    @Override
    protected void changeValue(SeasonRewardConfig config, SeasonRewardData data, Object param) {
        long value = (long) param;
        if (value > data.getValue()) {
            data.setValue(value);
        }
    }

    @Override
    protected boolean isComplete(SeasonRewardConfig config, SeasonRewardData data) {
        return data.getValue() >= config.getParamList().get(0);
    }

    @Override
    protected void addLog(SeasonRewardConfig config, SeasonRewardData data) {
        long seasonPlayTimes = 0;
        long seasonPlayTime = 0;
        WasheUserData userData = player.getModule(WasheModule.class).getWasheUserData();
        if (userData != null) {
            seasonPlayTimes = userData.getPlayTimes();
            seasonPlayTime = userData.getSeasonPlayTime();
        }

        AutoLogMgr.add(new LogWasheSeasonReward(
                data.getUserId(),
                config.getType(),
                config.getSeasonId(),
                config.getRewardId(),
                seasonPlayTimes,
                seasonPlayTime
        ));
    }
}
